package jp.tkym.labs.store;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 
 * @author kazunari
 *
 */
class DefaultDDLExecutor implements DDLExecutor{
	protected Connection connection;
	protected DDLStatementGenerator generator = new DDLStatementGenerator();
	
	DefaultDDLExecutor(Connection connection){
		this.connection = connection;
	}
	
	public void truncate(TableMeta param) throws SQLException{
		Statement statement = connection.createStatement();
		String sql = generator.truncate(param.tableName());
		statement.execute(sql);
	}
	
	public void create(TableMeta param) throws SQLException{
		Statement statement = connection.createStatement();
		String sql = generator.create(param);
		statement.execute(sql);
	}
	
	public void drop(TableMeta param)  throws SQLException{
		Statement statement = connection.createStatement();
		String sql = generator.drop(param);
		statement.execute(sql);
	}
}